package com.homwork.Bean;

import lombok.Builder;
import lombok.Data;

import java.util.ArrayList;

/**
 * 购物车小票·
 */
@Builder
@Data
public class Receipts {
    /*
    保存多个对象
     */
     private ArrayList<Shopping_cart> list;
    /**
     * 折扣
     */
    private final String discount="8折";
    /**
     * 消费总金额
     */
    private int consume;
    /**
     * 实际消费
     */
    private final int Actual_consume=1500;
    /**
     * 找钱
     */
    private double back;
    /**
     * 积分
     */
    private final int Integral=33;

    /**
     * 遍历商品
     *
     */
    public void Shop1(){
         for(Shopping_cart shoppingCart:list){
             consume+=shoppingCart.getAmount();
             System.out.println(shoppingCart.toString());
         }
    }

    @Override
    public String toString() {
        double a=consume * 0.8;
       back=Actual_consume-a;

        return "折扣:  "+ discount+"\n消费总金额:  "+consume
                +"\n实际消费"+Actual_consume+"\n找钱  "+back+
                "\n积分   "+Integral;

    }
}
